

<?php
require_once(dirname(__FILE__).'/../db/classDBHandler.php');


if(isset($_POST['s']))	
	$selected_option=$_POST['s'];
if(isset($_POST['className']))	
	$name=$_POST['className'];
	
/*	
	if(isset($_POST['s']))	
	{
		$find_result = classDBHandler::find_class($name, $selected_option);
		$num_results = mysql_num_rows($find_result);
	}
*/		

	switch($selected_option){
			
	case 0: //Find class details
			$find_result = classDBHandler::find_class($name, $selected_option);
			$num_results = mysql_num_rows($find_result);
			if($num_results>0)
			{
				$row = mysql_fetch_assoc($find_result);
				$answer="Class Name : ".$row['name']."<br/>Day : ".$row['day']."<br/> From : ".$row['start_time']."<br/> To : ".$row['end_time']."<br/> Guide: ".$row['teacher'];
			}
			break;
	case 1:
			//add class parameters	
				if(isset($_POST['teacherName']))	
					$teacher_name=$_POST['teacherName'];
				if(isset($_POST['Day']))	
					$day=$_POST['Day'];
				if(isset($_POST['startTime']))	
					$start_time=$_POST['startTime'];
				if(isset($_POST['endTime']))	
					$end_time=$_POST['endTime'];
				$object = (object) array('select'=>$selected_option,'name'=>$name,'teacher_name' => $teacher_name, 'day'=>$day, 'start_time'=>$start_time, 'end_time'=>$end_time);
			$find_result = classDBHandler::find_class($object, $selected_option);
				if($find_result)
					$answer= " New class details updated successfully !!!";
				else
					$answer= "Class name allready exist, please choose different name !!!";
				break;
		case 2:
					$answer= "On cunstruction !!!";
					
			
			
	
	}

	
	
	echo  $answer;
		
?>



